<template>
	<view>
		<view class="list-item" v-for="(item, index) in list" :key="index">
			<text>姓名：{{ item.name }}</text>
			<text>年龄：{{ item.age }}</text>
			<text>性别：{{ item.sex }}</text>
			<button @click="handleDelete(item._id)" size="mini">删除</button>
		</view>
		
		
		<view class="">
				------------------------
		</view>
		
		
		
	</view>
</template>



<script>
	const db = uniCloud.database();
	const list = db.collection('list');
	export default {
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				list.get().then(resp => {
					this.list = resp.result.data
				})
			},
			async handleDelete(id) {
				await list.doc(id).remove()
				await this.getList()
			}
		},
		data() {
			return {
				list:  []
			}
		}
	}
	
	
</script>